<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrappe">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="单据来源">
              <j-dict-select-tag placeholder="请选择单据来源" @input="handleDocumentSource" v-model="queryParam.permissionType" dictCode="permission_type"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24" v-if="queryParam.permissionType == 3">
            <a-form-item label="选择部门">
              <J-select-multiple
                placeholder="请选择选择部门"
                :options="getDepartName"
                showId="id"
                v-model="queryParam.deptIds"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24" v-if="queryParam.permissionType == 4">
            <a-form-item label="选择团队">
              <J-select-multiple
                placeholder="请选择选择团队"
                :options="getTeamName"
                showId="id"
                v-model="queryParam.teamIds"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="单据编号" class="form-item">
              <j-input placeholder="请输入单据编号" v-model="queryParam.billNo"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="申请人">
              <select-user-by-dep
                placeholder="请选择申请人"
                v-model="queryParam.proposer" />
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="申请公司">
              <select-Company-input v-model="queryParam.applicant" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="费用所属团队">
              <select-team-input placeholder="请选择费用所属团队" v-model="queryParam.teamId" :teamType="0" :tdlx="3"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="开始/结束时间" class="form-item">
              <a-range-picker
                v-model="createTimeRange"
                format="YYYY-MM-DD"
                :placeholder="['开始时间', '结束时间']"
                @change="onCreateTimeChange" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="报销金额" class="form-item">
              <a-input-number placeholder="请输入最小值" class="query-group-cust" :precision="2" v-model="queryParam.reimbursementAmount_begin" style="width:calc(50% - 15px);"></a-input-number>
              <span class="query-group-split-cust"></span>
              <a-input-number placeholder="请输入最大值" class="query-group-cust" :precision="2" :min="queryParam.reimbursementAmount_begin" v-model="queryParam.reimbursementAmount_end"
style="width:calc(50% - 15px);"></a-input-number>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="单据状态">
              <j-dict-select-tag placeholder="请选择单据状态" v-model="queryParam.bpmStatus" dictCode="bpm_status"/>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="是否付款">
              <j-dict-select-tag placeholder="请选择是否付款" v-model="queryParam.isPayFlag" dictCode="is_pay_flag"/>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="createTimeRange=[],searchReset()" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" :disabled="isDisabledAuth('erpFinanceReimbursementBill:add')">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('费用报销申请单')">导出</a-button>
      <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpFinanceReimbursementBill:import')">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--        <a-menu slot="overlay">-->
<!--          <a-menu-item key="1" @click="batchDel" :disabled="isDisabledAuth('erpFinanceReimbursementBill:delete')"><a-icon type="delete"/>删除</a-menu-item>-->
<!--        </a-menu>-->
<!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
<!--      </a-dropdown>-->
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item,index) in defColumns">
                <template v-if="item.key!='rowIndex'&& item.dataIndex!='action'">
                  <a-col :span="12" :key="index"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style="iconStyle"/></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:scrollX}"
        bordered
        rowKey="id"
        :components="draggableComponent"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <span slot="notify" slot-scope="text, record">
          <a-icon
            title="催办提醒"
            v-if="record.taskUrge"
            theme="twoTone"
            twoToneColor="#eb2f96"
            @click="taskNotifyMe(flowCode,record.id)"
            type="notification"
          />
          {{ text }}
        </span>
        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <span slot="money" slot-scope="text, record">
          {{ !record.reimbursementAmount?'0.00': record.reimbursementAmount.toFixed(2) }}/
          <a @click="getPaymentAmount(record)">{{ !record.totalPayAmount ?'0.00': record.totalPayAmount.toFixed(2) }}</a>
          /
          <a @click="getChargedAmount(record)">{{ !record.chargedAmount ?'0.00': record.chargedAmount.toFixed(2) }}</a>
        </span>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <a slot="billNo" slot-scope="text, record" @click="getDetail(record.id)">{{ text }}</a>
        <span slot="action" slot-scope="text, record">
          <template v-if="record.bpmStatus === '1'">
            <a-button
              class="ruleButton"
              :ghost="true"
              type="primary"
              icon="edit"
              @click="handleEdit(record)"
              :disabled="isDisabledAuth('erpFinanceReimbursementBill:edit')"
            />
            <a-divider type="vertical"/>
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a-button
                class="ruleButton"
                :ghost="true"
                type="primary"
                icon="delete"
                :disabled="isDisabledAuth('erpFinanceReimbursementBill:delete')"/>
            </a-popconfirm>
          </template>
          <template v-else-if="showBtn(record.bpmStatus)&&queryParam.bizTaskType=='1'">
            <a-button type="primary" size="small" @click="handleProcess(record)">办理</a-button>
            <a-divider type="vertical"/>
          </template>
          <template v-else-if="queryParam.bizTaskType=='2' && showBtn(record.bpmStatus)">
            <a-button type="primary" size="small" @click="taskNotify(flowCode,record.id)">催办</a-button>
            <a-divider type="vertical"/>
            <a-popconfirm title="确定要作废吗?" @confirm="() => invalidProcess(record)">
              <a-button type="primary" size="small" :disabled="isDisabledAuth('erpFinanceReimbursementBill:invalidProcess')">
                作废流程
              </a-button>
            </a-popconfirm>
            <a-divider type="vertical"/>
          </template>
          <template v-if="record.checkStatus == '2'">
          <!-- <template v-if="record.isPay == '1' && record.isPayFlag == '0' && record.isCancel == '0' && record.isSuspend == '0'">
            <a-popconfirm title="确定付款吗?" @confirm="() => handlePay(record)"  :disabled="isDisabledAuth('erpFinanceReimbursementBill:pay')">
              <a-button type="primary" size="small"  :disabled="isDisabledAuth('erpFinanceReimbursementBill:pay')">付款</a-button>
            </a-popconfirm>
            <a-divider type="vertical"/>
          </template> -->
            <!-- <template v-if="record.isPay == '1' && record.isPayFlag == '0' && record.isCancel == '0'">
          <a-popconfirm title="确定挂起吗?" @confirm="() => handleSuspend(record)" v-if="record.isSuspend=='0'" :disabled="isDisabledAuth('erpFinanceReimbursementBill:suspend')">
            <a-button type="primary" size="small" :disabled="isDisabledAuth('erpFinanceReimbursementBill:suspend')">挂起</a-button>
          </a-popconfirm>
          <a-popconfirm title="确定反挂起吗?" @confirm="() => handleSuspend(record)" v-else :disabled="isDisabledAuth('erpFinanceReimbursementBill:suspend')">
            <a-button type="primary" size="small" :disabled="isDisabledAuth('erpFinanceReimbursementBill:suspend')">反挂起</a-button>
          </a-popconfirm>
            <a-divider type="vertical"/>
        </template>
        <template v-if="record.isPay == '1' && record.isPayFlag == '0' && record.isCancel == '0' ">
          <a-popconfirm title="确定作废吗?" @confirm="() => handleCancel(record.id)" :disabled="isDisabledAuth('erpFinanceReimbursementBill:cancel')">
            <a-button type="primary" size="small" :disabled="isDisabledAuth('erpFinanceReimbursementBill:cancel')">作废</a-button>
          </a-popconfirm>
          <a-divider type="vertical"/>
        </template> -->
          </template>
          <template v-if="record.bpmStatus !== '1'">
            <a-button type="primary" size="small" @click="handleTrack(record)" :disabled="isDisabledAuth('erpFinanceReimbursementBill:viewTrack')">审批进度</a-button>
          </template>
        </span>
      </a-table>
    </div>

    <erp-finance-reimbursement-bill-modal ref="modalForm" @ok="modalFormOk"></erp-finance-reimbursement-bill-modal>
    <bpm-biz-task-deal-modal ref="taskDealModal" :path="path" :formData="formData" @ok="handleOk"></bpm-biz-task-deal-modal>
    <bpm-process-track-modal ref="bpmProcessTrackModal"></bpm-process-track-modal>
    <biz-task-notify-modal ref="taskNotifyModal"></biz-task-notify-modal>
    <biz-task-notify-me-modal ref="taskNotifyMeModal"></biz-task-notify-me-modal>
    <!-- 付款弹出框 -->
    <a-modal
      v-model="payFlag"
      title="付款" @ok="handlePayOk" :bodyStyle="{
      'height':'200px',
      'display':'flex',
      'justifyContent': 'center',
      'alignItems': 'center'
    }">
      <j-form-container >
        <a-form-model ref="form" :model="payModel" :rules="validatorRules" slot="detail">
          <a-row :gutter="48">
            <a-col :span="12">
              <a-form-model-item label="是否已付款" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isPayFlag">
                <j-dict-select-tag type="list" v-model="payModel.isPayFlag" dictCode="is_pay_flag" placeholder="请选择是否已付款" />
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="已付款金额(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payAmount">
                <a-input-number
                  :max="99999999"
                  :min="0"
                  v-model="payModel.payAmount"
                  placeholder="请输入已付款金额"
                  style="width: 100%"
                  disabled />
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="付款人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payHandlerId">
                <select-person-input
                  v-model="payModel.payHandlerId"
                  disabled/>
              </a-form-model-item>
            </a-col>
            <a-col :span="12">
              <a-form-model-item label="付款时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payTime">
                <j-date
                  placeholder="请输入付款时间"
                  v-model="payModel.payTime"
                  :show-time="true"
                  date-format="YYYY-MM-DD HH:mm:ss"
                  style="width: 100%"
                  disabled/>
              </a-form-model-item>
            </a-col>
            <a-input v-model="payModel.id" placeholder="id" type="hidden"></a-input>
          </a-row>
        </a-form-model>
      </j-form-container>
    </a-modal>
    <!-- 挂起弹出框 -->
    <a-modal
      v-model="suspendFlag"
      :title="suspendModel.isSuspend=='0'?'挂起':'反挂起'" @ok="handleSuspendOk" :bodyStyle="{
      'height':'200px',
    }">
      <j-form-container >
        <a-form-model ref="form" :model="suspendModel" :rules="validatorRules" slot="detail">
          <a-row :gutter="48" >
            <a-col :span="48" v-if="suspendModel.isSuspend=='0'">
              <a-form-model-item label="挂起原因" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="onSuspendRemarks">
                <a-textarea v-model="suspendModel.onSuspendRemarks" rows="4" placeholder="请输入挂起原因" :autosize="{ minRows: 4, maxRows: 4 }" />
              </a-form-model-item>
            </a-col>
            <a-col :span="48" v-else>
              <a-form-model-item label="反挂起原因" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="unSuspendRemarks">
                <a-textarea v-model="suspendModel.unSuspendRemarks" rows="4" placeholder="请输入反挂起原因" :autosize="{ minRows: 4, maxRows: 4 }"/>
              </a-form-model-item>
            </a-col>
            <a-input v-model="suspendModel.id" placeholder="id" type="hidden"></a-input>
          </a-row>
        </a-form-model>
      </j-form-container>
    </a-modal>
    <process-config-modal ref="processConfig" @ok="handleSuccess" @close="handleClose"></process-config-modal>
    <ErpFinanceDepositBillPenetrate ref="depositBillPenetrate"></ErpFinanceDepositBillPenetrate>
    <ErpFinancePaymentBillPenetrate ref="paymentBillPenetrate"></ErpFinancePaymentBillPenetrate>
    <ErpFinanceLoanBillPenetrate ref="loanBillPenetrate"></ErpFinanceLoanBillPenetrate>
    <ErpFinancePaymentBillListPenetrate ref="paymentBillListPenetrate"></ErpFinancePaymentBillListPenetrate>
    <ErpFinanceLoanBillListPenetrate ref="LoanBillListPenetrate"></ErpFinanceLoanBillListPenetrate>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgBpmListMixin } from '@/mixins/JeecgBpmListMixin'
  import BpmBizTaskDealModal from '@/views/modules/bpmbiz/common/BpmBizTaskDealModal.vue';
  import BpmProcessTrackModal from '@/views/modules/bpmbiz/common/BpmProcessTrackModal.vue';
  import BizTaskNotifyModal from '@/views/modules/bpmbiz/common/BizTaskNotifyModal.vue';
  import BizTaskNotifyMeModal from '@/views/modules/bpmbiz/common/BizTaskNotifyMeModal.vue';
  import ErpFinanceReimbursementBillModal from './modules/ErpFinanceReimbursementBillModal'
  import { postAction , httpAction, getAction } from '@/api/manage'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import moment from 'moment'
  import { mapGetters } from 'vuex'
  import SelectPersonInput from '@/views/scy/components/SelectPersonInput'
  
  import ProcessConfigModal from '@/views/scy/components/ProcessConfigModal'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import ErpFinanceDepositBillPenetrate from '@/views/scy/penetrate/ErpFinanceDepositBillPenetrate'
  import ErpFinancePaymentBillPenetrate from '@/views/scy/penetrate/ErpFinancePaymentBillPenetrate'
  import ErpFinanceLoanBillPenetrate from '@/views/scy/penetrate/ErpFinanceLoanBillPenetrate'
  import ErpFinancePaymentBillListPenetrate from '@/views/scy/penetrate/ErpFinancePaymentBillListPenetrate'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import ErpFinanceLoanBillListPenetrate from '@/views/scy/penetrate/ErpFinanceLoanBillListPenetrate'

  export default {
    name: 'ErpFinanceReimbursementBillList',
    mixins: [JeecgBpmListMixin, mixinDevice, DisabledAuthFilterMixin],
    props: { flag: false },
    components: {
      ErpFinanceReimbursementBillModal,
      BpmBizTaskDealModal,
      BpmProcessTrackModal,
      BizTaskNotifyModal,
      BizTaskNotifyMeModal,
      SelectPersonInput,
      ProcessConfigModal,
      SelectCompanyInput,
      ErpFinanceDepositBillPenetrate,
      ErpFinancePaymentBillPenetrate,
      ErpFinanceLoanBillPenetrate,
      ErpFinancePaymentBillListPenetrate,
      SelectTeamInput,
      SelectUserByDep,
      ErpFinanceLoanBillListPenetrate
    },
    data () {
      return {
        createTimeRange: [],
        // 付款model
        payModel: {},
        // 挂起model
        suspendModel: {},
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 }
        },
        validatorRules: {
          isPayFlag: [{ required: true, message: '请选择是否付款!' }],
          payAmount: [{ required: true, message: '请选择是否付款!' }],
          payHandlerId: [{ required: true, message: '请选择联系人!' }],
          payTime: [{ required: true, message: '请选择支付时间!' }]
        },
        suspendFlag: false,
        payFlag: false,
        description: '费用报销申请单管理页面',
        // 表头
        columns: [],
        // 列设置
        settingColumns: [],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key: 'rowIndex',
            width: 60,
            align: 'center',
            customRender: function (t, r, index) {
              return parseInt(index) + 1;
            }
          },
          {
            title: '单据编号',
            align: 'center',
            width: 180,
            dataIndex: 'billNo',
            scopedSlots: { customRender: 'billNo' },
            ellipsis: true
          },
          {
            title: '申请人',
            align: 'center',
            dataIndex: 'proposer_dictText',
            width: 100,
            ellipsis: true
          },
          {
            title:'申请部门',
            align:"center",
            dataIndex: 'proposerDeptId_dictText',
            width:150,
            ellipsis: true,
          },
          {
            title: '申请公司',
            align: 'center',
            width: 200,
            dataIndex: 'applicant_dictText',
            ellipsis: true
          },
          {
            title: '费用所属团队',
            align: 'center',
            dataIndex: 'teamId_dictText',
            width: 250,
            ellipsis: true
          },
          {
            title: '报销金额（元）/已付金额（元）/冲账金额（元）',
            align: 'center',
            width: 350,
            dataIndex: 'money',
            scopedSlots: { customRender: 'money' },
            ellipsis: true
          },
          {
            title: '本次付款金额（元）',
            align: 'center',
            width: 150,
            dataIndex: 'payAmount',
            ellipsis: true
          },
          {
            title:'是否付款',
            align:"center",
            width:80,
            dataIndex: 'isPay_dictText',
            ellipsis: true
          },
          {
            title: '报销说明',
            align: 'center',
            width: 80,
            dataIndex: 'applyExplain',
            ellipsis: true
          },
          {
            title: '流程状态',
            align: 'center',
            width: 80,
            dataIndex: 'bpmStatus_dictText',
            ellipsis: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            fixed: 'right',
            width: 150,
            scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action' }
          }
        ],
        url: {
          list: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/list',
          delete: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/delete',
          deleteBatch: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/deleteBatch',
          exportXlsUrl: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/exportXls',
          importExcelUrl: 'api/erp/finance/reimbursement/erpFinanceReimbursementBill/importExcel',
          bizCount: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/bizCount',
          pay: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/pay', // 付款
          suspend: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/suspend', // 挂起
          cancel: '/api/erp/finance/reimbursement/erpFinanceReimbursementBill/cancel' // 作废
        },
        id: '',
        // 代码生成后需手动设置流程编码
        flowCode: 'onl_erp_finance_reimbursement_bill',
        formUrl: '/erp/finance/reimbursement/modules/ErpFinanceReimbursementBillForm',
        formUrlMobile: '/pages/synergy/erpFinanceReimbursementBillList',
        dictOptions: {},
        superFieldList: [],
        processId: '1559825734534545409',
        beanName: 'erpFinanceReimbursementBillServiceImpl'
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function() {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      // 打开付款弹窗
      getPaymentAmount(record) {
        // 先清空数据
        this.$refs.paymentBillListPenetrate.dataSource = []
        this.$refs.paymentBillListPenetrate.ipagination.total = 0
        // 查询数据
        this.$refs.paymentBillListPenetrate.loading = true
        this.$refs.paymentBillListPenetrate.relReimbursementBillId = record.id
        this.$refs.paymentBillListPenetrate.searchReset()
         // 打开弹窗
        this.$refs.paymentBillListPenetrate.visible = true
      },
      // 打开冲账弹窗
      getChargedAmount(record) {
        console.log(record);
        if (record.relBillType == '1') {
          getAction('/api/erp/finance/reimbursement/erpFinanceReimbursementChargedBillInfo/querySalaryFeeListById',{ billId: record.id }).then(res => {
            console.log(res);
            if(res.success){
              if(res.result.length){
                let data = res.result.map(v => v.relBillId).join(',')
                this.$refs.LoanBillListPenetrate.id = data
                this.$refs.LoanBillListPenetrate.searchResets()
                this.$refs.LoanBillListPenetrate.visible = true
              }
            }
          })

        } else if (record.relBillType == '2') {
          getAction('/api/erp/finance/reimbursement/erpFinanceReimbursementChargedBillInfo/querySalaryFeeListById',{ billId: record.id }).then(res => {
            console.log(res);
            if(res.success){
              if(res.result.length){
                let data = res.result.map(v => v.relBillId).join(',')
                this.$refs.paymentBillListPenetrate.type = 'salary'
                this.$refs.paymentBillListPenetrate.relReimbursementBillId = data
                this.$refs.paymentBillListPenetrate.searchReset()
                this.$refs.paymentBillListPenetrate.visible = true
              }
            }
          })

        } else if (record.relBillType == '3') {
          this.$refs.depositBillPenetrate.initData(record.relBillId);
          this.$refs.depositBillPenetrate.visible = true;
        }
      },
      // 发起流程
      beginProcess(record) {
        this.$refs.processConfig.visible = true
        this.$refs.processConfig.formUrl = this.formUrl
        this.$refs.processConfig.formUrlMobile = this.formUrlMobile
        this.$refs.processConfig.flowCode = this.flowCode
        this.$refs.processConfig.edit(record, '', this.beanName)
      },
      handleSuccess() {
        this.loadData();
        this.$refs.modalForm.handleCancel()
        this.onClearSelected();
      },
      onCreateTimeChange(dateString) {
        this.queryParam.createTime_begin = moment(dateString[0]).format('YYYY-MM-DD');
        this.queryParam.createTime_end = moment(dateString[1]).format('YYYY-MM-DD');
      },
      // 流程审批结束禁用
      getCheckboxProps(record) {
        return {
          props: {
            disabled: record.bpmStatus !== '1'
          }
        }
      },
      // 查看详情
      getDetail(id) {
        this.$router.push({
          path: `/erp/finance/reimbursement/ErpFinanceReimbursementBillListDetail/${id}`
        })
      },
      ...mapGetters(['userInfo']),
      // 付款
      handlePay(record) {
        this.$set(this.payModel, 'isPayFlag', null);
        this.payFlag = true;
        this.$set(this.payModel, 'id', record.id);
        this.$set(this.payModel, 'payAmount', record.payAmount);
        this.$set(this.payModel, 'payTime', moment().format('YYYY-MM-DD HH:mm:ss'));
        this.$set(this.payModel, 'payHandlerId', this.userInfo().empId);
      },
      handlePayOk() {
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
              // 确定支付
              if (this.payModel.isPayFlag == '1') {
                httpAction(this.url.pay, this.payModel, 'PUT').then((res) => {
                  if (res.success) {
                    this.$message.success('付款成功！')
                    this.loadData(1);
                  }
                })
              }
              this.payFlag = false;
          }
        })
      },
      // 挂起
      handleSuspend(record) {
        this.suspendFlag = true;
        this.$set(this.suspendModel, 'id', record.id);
        this.$set(this.suspendModel, 'isSuspend', record.isSuspend);
      },
      handleSuspendOk() {
        // 判断当前挂起状态
        if (this.suspendModel.isSuspend == '1') {
          this.suspendModel.isSuspend = '0';
        } else {
          this.suspendModel.isSuspend = '1';
        }
        httpAction(this.url.suspend, this.suspendModel, 'PUT').then((res) => {
          if (res.success) {
            this.$message.success('操作成功！')
            this.loadData(1);
          }
        })
        this.suspendFlag = false;
      },
      // 作废
      handleCancel(id) {
        let param = { 'id': id };
        httpAction(this.url.cancel, param, 'PUT').then((res) => {
          if (res.success) {
            this.$message.success('操作成功！')
            this.loadData(1);
          } else {

          }
        })
      },
      handleEdit: function (record) {
        this.$refs.modalForm.edit(record, true);
        this.$refs.modalForm.title = '编辑'
        this.$refs.modalForm.disableSubmit = false
      },
      initDictConfig() {
      },
      getSuperFieldList() {
        let fieldList = [];
        fieldList.push({ type: 'string', value: 'handlerId', text: '经办人编号', dictCode: '' })
        fieldList.push({ type: 'string', value: 'handlerDeptId', text: '经办人部门ID', dictCode: '' })
        fieldList.push({ type: 'string', value: 'handlerDeptCode', text: '经办人部门编码', dictCode: '' })
        fieldList.push({ type: 'string', value: 'applicant', text: '申请公司', dictCode: '' })
        fieldList.push({ type: 'string', value: 'billNo', text: '单据编号', dictCode: '' })
        fieldList.push({ type: 'string', value: 'isPay', text: '是否付款', dictCode: 'is_pay' })
        fieldList.push({ type: 'BigDecimal', value: 'payAmount', text: '本次付款金额', dictCode: '' })
        fieldList.push({ type: 'string', value: 'feeCategory', text: '费用类别', dictCode: '' })
        fieldList.push({ type: 'string', value: 'remark', text: '备注', dictCode: '' })
        fieldList.push({ type: 'string', value: 'settleType', text: '结算方式', dictCode: 'settle_type' })
        fieldList.push({ type: 'string', value: 'accountName', text: '收款户名', dictCode: '' })
        fieldList.push({ type: 'string', value: 'bankName', text: '收款开户行', dictCode: '' })
        fieldList.push({ type: 'string', value: 'accountNo', text: '收款账号', dictCode: '' })
        fieldList.push({ type: 'string', value: 'relBillId', text: '关联单据单号', dictCode: '' })
        fieldList.push({ type: 'string', value: 'relBillType', text: '关联单据类型', dictCode: '' })
        fieldList.push({ type: 'Text', value: 'attachments', text: '附件', dictCode: '' })
        fieldList.push({ type: 'string', value: 'applyExplain', text: '报销说明', dictCode: '' })
        fieldList.push({ type: 'string', value: 'bpmStatus', text: '流程状态', dictCode: '' })
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
